package org.ws.task.event.support.startup;

import io.netty.channel.Channel;
import org.ws.task.model.NodeMetadata;
import org.ws.task.model.TaskConfig;

/**
 * 启动时事件类型
 */
public enum BootstrapEventType {
    BECOME_LEADER(0,"成为Leader", NodeMetadata.class),
    CHANGE_LEADER(1,"变更Leader",NodeMetadata.class),
    REMOVE_LEADER(2,"删除Leader",NodeMetadata.class),
    NOT_LEADER(3,"不是Leader",NodeMetadata.class),
    NOT_FOUND_LEADER(4,"没有找到Leader",NodeMetadata.class),
    CHECK_LEADER(5,"检查Leader",Integer.class),
    UPDATE_WORKER(10,"更新Worker",NodeMetadata.class),
    REMOVE_WORKER(11,"删除Worker",NodeMetadata.class),
    SERVER_STARTUP(20,"服务端已启动",Integer.class),
    CHANNEL_CONNECT(21,"已连接", String.class),
    CHANNEL_CLOSE(22,"已断开", String.class),
    CHANNEL_IDLE(23,"已超时", String.class),
    CLIENT_STARTUP(30,"客户端已启动",Integer.class),
    CLIENT_CHANNEL_CONNECT(31,"客户端已连接",Integer.class),
    CLIENT_CHANNEL_IDLE(32,"客户端已超时",Channel.class),
    UPDATE_TASK_CONFIG(40,"更新任务配置", TaskConfig.class),
    REMOVE_TASK_CONFIG(41,"删除任务配置", TaskConfig.class),
    BOOTSTRAP_STARTING(50,"启动中",Boolean.class),
    BOOTSTRAP_SUCCESS(51,"启动成功",Boolean.class);

    private int code;
    private String name;
    private Class sourceClass;

    BootstrapEventType(int code,String name, Class sourceClass) {
        this.code = code;
        this.name = name;
        this.sourceClass = sourceClass;
    }

    public int getCode() {
        return this.code;
    }

    public String getName() {
        return name;
    }

    public Class getSourceClass() {
        return this.sourceClass;
    }

}
